import express from 'express';
import fs from 'fs';
import path from 'path';
const router = express.Router();

export = (app: any) => {
  app.use('/node/html', router);

  router.get('/file', (req: any, res: any) => {
    const filePath = path.join(__dirname, '../public/file.html');
    fs.readFile(filePath, 'utf8', (err, data) => {
      if (err) res.writeHead(404, { 'Content-Type': 'text/html' });
      res.writeHead(200, { 'Content-Type': 'text/html' });
      res.write(data.toString());
      res.end();
    });
  });
};
